package com.tom.architect.day18.simple3.bottomtab;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

// 基类
public abstract class BottomTabItem {
    // 布局id，上下文，
    private View mTabItemView; // 布局
    private int mLayoutId; // 布局id
    private Context mContext;

    public BottomTabItem(int layoutId, Context context) {
        this.mLayoutId = layoutId;
        this.mContext = context;
    }

    // 获取底部item的显示。
    public View getTabView() {
        if (mTabItemView == null) {
            mTabItemView = LayoutInflater.from(mContext).inflate(mLayoutId, null);
            initLayout();
        }
        return mTabItemView;
    }

    //  初始化显示
    protected abstract void initLayout();

    protected <T> T findViewById(int id) {
        return (T) mTabItemView.findViewById(id);
    }

    // 是否选中当前item
    protected  abstract void setSelected(boolean selected);

}
